$('.seach').keyup((event) => {
	// 添加记录
	if (event.which === 13) {
		seachVal = $('.seach').val()
		loacaGet = localStorage.getItem('key')
		if (loacaGet) {
			var lishival = JSON.parse(loacaGet)
			lishival.push(seachVal)
			localStorage.setItem('key', JSON.stringify(lishival))
		}
		else {
			localStorage.setItem('key', `[${seachVal}]`)
		}
		var lengths = JSON.parse(localStorage.getItem('key')).length - 1
		$('.historical-search-box').prepend(`
			<div class="historical-box">
				<div class="clock"><i class="iconfont">&#xe74f;</i></div>
					<div>${JSON.parse(localStorage.getItem('key'))[lengths]}</div>
				<div class="X" id="${lengths}">×</div>
			</div>	
			`)
	}
	// 删除记录
	$('.X').click(() => {
		$('.X').parents('.historical-box').remove()
		var b = JSON.parse(localStorage.getItem('key'))
		b.splice($(this).attr('id'), 1);
		localStorage.setItem('key', JSON.stringify(b))
	})
})
// 获取现有的记录添加
$.each(JSON.parse(localStorage.getItem('key')), (index, item) => {
	$('.historical-search-box').prepend(`
        <div class="historical-box">
				<div class="clock"><i class="iconfont">&#xe74f;</i></div>
					<div>${JSON.parse(localStorage.getItem('key'))[index]}</div>
				<div class="X" id="${index}">×</div>
			</div>	
        `)
})
// 删除记录2
$('.X').click(() => {
	$('.X').parents('.historical-box').remove()
	var b = JSON.parse(localStorage.getItem('key'))
	b.splice($(this).attr('id'), 1);
	localStorage.setItem('key', JSON.stringify(b))
})